home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Risc World 3
/
Risc World 3.iso
/
SOFTWARE
/
ISSUE6
/
PD
/
PDF
/
GuiLib
/
Wimp
/
h
/
GuiWimp
< prev
next >
Wrap
Text File
|
2003-02-14
|
7KB
|
226 lines
//--------------------------------------------------------------------------
//
// Copyright (c) 2002, Colin Granville
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following
// conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// * The name Colin Granville may not be used to endorse or promote
// products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
//--------------------------------------------------------------------------
#ifndef GuiWimp_h
#define GuiWimp_h
#include "GuiWimpSwis.h"
#include "GuiBBox.h"
#include "GuiIcon.h"
#include "GuiWimpWindow.h"
#include "swis.h"
//*********************************************************************
// Caret
//*********************************************************************
class GuiMouseClickBlock
{
public:
int x;
int y;
int buttons;
int windowHandle;
int iconHandle;
void get() {_swix(Wimp_GetPointerInfo,_IN(1),this);}
};
#include "GuiWimpMessage.h"
class GuiPointerInfo : public GuiMouseClickBlock
{
public:
enum {Adjust=1,Menu=2,Select=4};
GuiPointerInfo() {get();}
};
//*********************************************************************
// Caret
//*********************************************************************
class GuiCaretPositionBlock
{
public:
int windowHandle;
int iconHandle;
int xoffset;
int yoffset;
int height;
int index;
void get() {_swix(Wimp_GetCaretPosition,_IN(1),this);}
};
class GuiCaretPosition : public GuiCaretPositionBlock
{
public:
GuiCaretPosition() {get();}
static void set(int window_handle,int icon_handle,int xoffset,int yoffset,int height,int index)
{_swix(Wimp_SetCaretPosition,_INR(0,5),window_handle,icon_handle,xoffset,yoffset,height,index);}
};
//*********************************************************************
// Drag
//*********************************************************************
class GuiDragBox
{
public:
enum //dragType
{
DragPoint = 7,
};
int windowHandle;
int dragType;
GuiBBox draggingBox;
GuiBBox parentBox;
int* workspace;
void (*draw)();
void (*remove)();
void (*move)();
GuiDragBox() {}
void startDrag(int drag_type) {dragType=drag_type;_swix(Wimp_DragBox,_IN(1),this);}
static void cancelDrag() {_swix(Wimp_DragBox,_IN(1),0);}
};
//***************************************************************************
//* Events *
//***************************************************************************
class GuiKeyPressedEvent
{
public:
GuiCaretPositionBlock caret;
int keyCode;
};
class GuiScrollRequestEvent
{
public:
struct Open : public GuiWindowPositionBlock
{
int behind;
} open;
int xscroll;
int yscroll;
// because an GuiOpenWindowBlock is extended for the nested wimp
// a GuiScrollRequestEvent needs to be cast to a GuiWindowOpenBlock
// for the window show() method
GuiOpenWindowBlock& openBlock() {return (GuiOpenWindowBlock&)*this;}
};
class GuiPollWordNonZeroEvent
{
public:
void* pollWord;
int pollWordContents;
};
struct GuiCloseWindowRequestEvent
{
int windowHandle;
};
struct GuiUserDragBoxEvent
{
GuiBBox bbox;
};
//event codes returned in r0 from SWI Wimp_Poll
#define GuiWimp_ENull 0
#define GuiWimp_ERedrawWindow 1
#define GuiWimp_EOpenWindow 2
#define GuiWimp_ECloseWindow 3
#define GuiWimp_EPointerLeavingWindow 4
#define GuiWimp_EPointerEnteringWindow 5
#define GuiWimp_EMouseClick 6
#define GuiWimp_EUserDrag 7
#define GuiWimp_EKeyPressed 8
#define GuiWimp_EMenuSelection 9
#define GuiWimp_EScrollRequest 10
#define GuiWimp_ELoseCaret 11
#define GuiWimp_EGainCaret 12
#define GuiWimp_EPollWordNonZero 13
#define GuiWimp_EUserMessage 17
#define GuiWimp_EUserMessageRecorded 18
#define GuiWimp_EUserMessageAcknowledge 19
#define GuiWimp_EToolboxEvent 0x200
typedef GuiRedrawWindowBlock GuiRedrawWindowRequestEvent;
typedef GuiOpenWindowBlock GuiOpenWindowRequestEvent;
typedef GuiCloseWindowRequestEvent GuiPointerLeavingWindowEvent,
GuiPointerEnteringWindowEvent;
typedef GuiMouseClickBlock GuiMouseClickEvent;
typedef int GuiMenuSelectionEvent[9];
typedef GuiCaretPositionBlock GuiGainCaretEvent,
GuiLoseCaretEvent;
typedef GuiWimpMessage GuiUserMessageEvent,
GuiUserMessageRecordedEvent,
GuiUserMessageAcknowledgeEvent;
typedef union
{
int words[64];
char bytes[256];
GuiRedrawWindowRequestEvent redrawWindowRequest;
GuiOpenWindowRequestEvent openWindowRequest;
GuiCloseWindowRequestEvent closeWindowRequest;
GuiPointerLeavingWindowEvent pointerLeavingWindow;
GuiPointerEnteringWindowEvent pointerEnteringWindow;
GuiMouseClickEvent mouseClick;
GuiUserDragBoxEvent userDragBox;
GuiKeyPressedEvent keyPressed;
GuiMenuSelectionEvent menuSelection;
GuiScrollRequestEvent scrollRequest;
GuiLoseCaretEvent loseCaret;
GuiGainCaretEvent gainCaret;
GuiPollWordNonZeroEvent pollWordNonZero;
GuiUserMessageEvent userMessage;
GuiUserMessageRecordedEvent userMessageRecorded;
GuiUserMessageAcknowledgeEvent userMessageAcknowledge;
} GuiWimpPollBlock;
#endif